package ec.atreasure.com.ec.main.index;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.LinkedHashMap;

import ec.atreasure.com.core.fragments.bottom.BaseBottomFragment;
import ec.atreasure.com.core.fragments.bottom.BottomItemBuilder;
import ec.atreasure.com.core.fragments.bottom.BottomItemFragment;
import ec.atreasure.com.core.fragments.bottom.BottomTabBean;
import ec.atreasure.com.ec.R;
import ec.atreasure.com.ui.refresh.RefreshHandler;

/**
 * Description :
 * Created by wangjin on 2019/7/7.
 * Job number：
 * Phone ：18301070822
 * Email： 120182051@qq.com
 * Person in charge : 汪渝栋
 * Leader：
 */
public class IndexFragment extends BottomItemFragment {

    //下拉刷新
    private SwipeRefreshLayout mSwipeRefreshLayout;

    //商品列表
    private RecyclerView mRecyclerView;

    //商品搜索框
    private AppCompatEditText mSearch;

    //下拉刷新逻辑控制
    private RefreshHandler mRefreshHandler;

    @Override
    public Object setLayout() {
        return R.layout.index_fragment;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View rootView) {
        mSwipeRefreshLayout = findViewById(R.id.srl_index);
        mRecyclerView = findViewById(R.id.rv_index);
        mSearch = findViewById(R.id.et_search_view);

        mRefreshHandler = new RefreshHandler(mSwipeRefreshLayout);

    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        initRefreshLayout();
    }

    /**
     * 设置下拉刷新样式
     */
    private void initRefreshLayout() {
        mSwipeRefreshLayout.setColorSchemeResources(
                android.R.color.holo_blue_bright
//                android.R.color.holo_orange_light,
//                android.R.color.holo_red_light
        );
        mSwipeRefreshLayout.setProgressViewOffset(true, 120, 260);
    }
}
